<%@ page contentType="text/html; charset=UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="path" value="${pageContext.request.contextPath}"></c:set>
<%@ page
	import="java.util.*,com.aide.simplification.popedom.login.*,com.aide.simplification.global.*"%>

<%@page import="java.nio.charset.Charset"%><html>
<head>
<title>后台登陆</title>
<style type="text/css">
<!--
body,td,th {
	margin: 0px;
	font-size: 12px;
	color: #333333;
}

/*Login*/
.loginfont {
	font-size: 12px;
	color: #333333;
}

.loginform {
	margin-left: 25px;
	line-height: 40px;
}

.logininput {
	border: 1px solid #84A1BD;
	background-color: #E8F9FF;
	height: 25px;
	font-size: 12px;
	color: #333333;
}

.loginbotton {
	background-image: url(simplification/expimages/check/loginbotton.jpg);
	background-repeat: no-repeat;
	border-width: 0;
	cursor: pointer;
	white-space: 0;
	width: 86px;
	height: 33px;
}
-->
</style>
</head>
<body bgcolor="#ffffff" style="overflow: hidden">
<%
	try {
		String username = "";
		if (request.getParameter("username") != null) {
			username = request.getParameter("username");
		}
		String password = "";
		if (request.getParameter("password") != null) {
			password = request.getParameter("password");
		}
		String type = "";
		if (request.getParameter("type") != null) {
			type = request.getParameter("type");
		}
		String checkcode = "";
		if (request.getParameter("checkcode") != null) {
			checkcode = request.getParameter("checkcode");
		}
		LoginUser lu = null;
		PopSSO popsso = new PopSSO(request, response);
		if (type.equals("logout")) {
			popsso.ssoLogout();
		}
		if (!type.equals("logout") && username.equals("")
				&& password.equals("")) {
			lu = popsso.ssoSync();
		} else {
			if (type.equals("login")) {
				if (checkcode.equals(session.getAttribute("checkcode")
						.toString())) {
					lu = popsso.ssoLogin(username, password);
					if (lu == null) {
%>
<script type="text/javascript">
       alert('用户名或密码错误！');
       </script>
<%
	}
				} else {
%>
<script type="text/javascript">
       alert('验证码错误！');
       </script>
<%
	}
			}
		}
		if (lu != null) {
			if(lu.getSign()==0){
				session.removeAttribute("loginUser");
				%>
				<script type="text/javascript">
				alert("用户被禁用！");
window.location="${path}/";
</script>
				<%
			}
			request.setAttribute("url", popsso.getURLParameter());
%>
<script type="text/javascript">
       window.location="${url}";
       </script>
<%
	}
	} catch (Exception e) {
		e.printStackTrace();
	}
%>


<form id="form1" action="${path}/?type=login" method="post"><c:if
	test="${param.url!=null&&param.url!=''}">
	<input id="url" name="url" type="hidden" value="${param.url }" />
</c:if>
<table width="80%" border="0" cellpadding="0" cellspacing="0"
	class="loginform">
	<c:if test="${param.url==null||param.url==''}">
		<tr>
			<td width="26%" align="right" valign="middle" class="loginfont">
			系统：</td>
			<td width="74%"><select id="url" name="url">
				<%
					GlobalConfig gc = new GlobalConfig();
						Iterator<String> it = gc.getRegex("system\\.\\w+\\.","system");
						while (it.hasNext()) {
							String key = it.next();
							String id = gc.getString(key+"page");
							String name = gc.getString(key+"name");
				%>
				<option value="<%=id%>"><%=name%></option>
				<%
					}
				%>
			</select></td>
		</tr>
	</c:if>
	<tr>
		<td width="26%" align="right" valign="middle" class="loginfont">
		用户名：</td>
		<td width="74%"><input name="username" type="text"
			class="logininput" id="username" size="25" style="width: 150px;">
		</td>
	</tr>
	<tr>
		<td align="right" valign="middle" class="loginfont">密 码：</td>
		<td><input name="password" type="password" class="logininput"
			id="password" size="25" style="width: 150px;"></td>
	</tr>
	<tr>
		<td class="loginfont" align="right" valign="middle">验证码：</td>
		<td><input type="text" autocomplete="off" name="checkcode"
			maxlength="4" class="logininput" style="width: 98px;" /> <img
			border="0" id="img" src="${path }/simplification/piccheck.jsp"
			alt="验证码"
			onClick="javascript:this.src='${path }/simplification/piccheck.jsp'"
			height="19" width="50" style="cursor: hand" /></td>
	</tr>
	<tr>
		<td class="loginfont" colspan="2" align="center" valign="middle"><input
			type="submit" name="submit" id="submit" value="" class="loginbotton"></td>
	</tr>
</table>
</form>
</body>
</html>